import java.io.FileReader;
import java.io.FileWriter;

public class watcher {
	public static void main(String[] args) throws Exception {
		System.out.println("From file: " + getVMsToAddAndReset("/tmp/file1"));
	}
	
	static int getVMsToAddAndReset(String filename) throws Exception {
		FileReader file = new FileReader(filename);
		StringBuffer fileContents = new StringBuffer();
		while (file.ready()) {
			int read = file.read();
			if (read!=0 && read!=10 && read!=13 && read!=26) {
				fileContents.append((char)read);
			}
		}
		file.close();
		file = null;
		FileWriter filewrite = new FileWriter(filename,false);
		filewrite.close();
		return Integer.parseInt(fileContents.toString());
	}
}